<template>
	<view class="goods_detail">
		<swiper indicator-dots>
			<swiper-item v-for="(item,index) in swipers" :key="index">
				<image :src="item.src"></image>
			</swiper-item>
		</swiper>
		
		<view class="box1">
			<view class="price">
				<text>￥{{info.sell_price}}</text>
				<text>￥{{info.market_price}}</text>
			</view>
			
			<view class="goods_name">{{info.title}}</view>
		</view>
		
		<view class="line"></view>
		
			<view class="box2">
				<view>货号:{{info.goods_no}}</view>
				<view>库存：{{info.stock_quantity}}</view>
				<view >时间：{{info.add_time | formatDate}}</view>
			</view>
			
		<view class="line"></view>
		
		<view class="box3">
			<view class="tit">
				详情介绍
			</view>
			<view class="content">
				<rich-text :nodes="content.content"></rich-text>
			</view>
		</view>
		
		<view class="cart"><uni-goods-nav :fill="true" :options="options" 
		   :button-group="customButtonGroup" 
		   @click="onClick"@buttonClick="buttonClick" /></view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				swipers:[],
				info:{},
				content:{},
				options: [{
									icon: 'chat',
									text: '客服'
								}, {
									icon: 'shop',
									text: '店铺',
									info: 0,
									infoBackgroundColor: '#007aff',
									infoColor: "#f5f5f5"
								}, {
									icon: 'cart',
									text: '购物车',
									info: 0
								}],
				customButtonGroup: [{
										text: '加入购物车',
										backgroundColor: 'linear-gradient(90deg, #1E83FF, #0053B8)',
										color: '#fff'
									},
									{
										text: '立即购买',
										backgroundColor: 'linear-gradient(90deg, #60F3FF, #088FEB)',
										color: '#fff'
									}
								],
			}
		},
		methods: {
			async getSwipers(){
				const res=await this.$myRequest({
					url:'api/getthumimages/:imgid'+this.id
				})
				this.swipers=res.data.message
			},
			
			async getDetailInfo(){
				const res=await this.$myRequest({
					url:'api/goods/getinfo/'+this.id
				})
				// console.log(res)
				this.info=res.data.message[0]
			},
			
			async getdesc(){
				const res=await this.$myRequest({
					url:"api/goods/getdesc/"+this.id
				})
				this.content=res.data.message[0]
			},
			
			onClick(e) {
				uni.showToast({
				title: `点击${e.content.text}`,
				icon: 'none'
					})
						},
				buttonClick(e) {
					console.log(e)
					this.options[2].info++
			}
		},
		
			
		
		onLoad(options) {
			this.id=options.id
			this.getSwipers()
			this.getDetailInfo()
			this.getdesc()
		}
	}
</script>

<style lang="scss">
.goods_detail{
	swiper{
		height: 700rpx;
		image{
			width:100%;
			height: 100%;
		}
	}
.box1{
	padding: 10px;
	.price{
		font-size: 30rpx;
		color:$shop-color;
		line-height: 80rpx;
		text:nth-child(2){
			color:#ccc;
			font-size: 28rpx;
			text-decoration: line-through;
			margin-left: 20rpx;
		}
	}
	.goods_name{
		font-size: 32rpx;
		line-height: 60rpx;
	}
  }
  .box2{
	  padding: 0 10px;
	  font-size: 32rpx;
	  line-height: 70rpx;
  }
  .box3{
	  
	  .tit{
		  font-size: 32rpx;
		  padding-left: 10px;
		  border-bottom: 1px solid #eee;
		  line-height: 70rpx;
	  }
	  .content{
		  padding: 10px;
		  font-size: 28rpx;
		  color: #333;
		  line-height: 50rpx;
	  }
  }
}

.cart{
	position: fixed;
	bottom:0;
	width: 100%;
}

.line{
	height: 10rpx;
	width: 750rpx;
	background:#eee;
}

</style>
